//显示咨询者成绩
<template>
  <div class="table">

    <section class="content-el">

      <el-form :inline="true" :model="formInline" class="demo-form-inline" size="small">
        <el-form-item label="试题名称">
          <el-input v-model="formInline.source" placeholder="请输入试题名称"></el-input>
        </el-form-item>
        <el-form-item>
          <el-button type="primary" @click="getScore()" size="small">查询</el-button>
          <el-button type="warning" @click="resetGetScore()" size="small">重置</el-button>

        </el-form-item>
      </el-form>
      <el-table ref="filterTable" :data="score" v-loading="loading">
        <el-table-column
          prop="source"
          label="试题名称"
          >
        </el-table-column>
        <el-table-column
          prop="studentName"
          label="测试人">
        </el-table-column>
        <el-table-column prop="createDate" label="测试时间" width="200"></el-table-column>

        <el-table-column fixed="right" label="操作">
          <template slot-scope="scope">
            <el-button @click="view(scope.row)" type="primary" size="small">查看详情</el-button>
          </template>
        </el-table-column>
      </el-table>
      <el-row type="flex" justify="center" align="middle" class="pagination">
        <el-pagination
          @size-change="handleSizeChange"
          @current-change="handleCurrentChange"
          :current-page="pagination.current"
          :page-sizes="[10,20]"
          :page-size="pagination.size"
          layout="total, sizes, prev, pager, next, jumper"
          :total="pagination.total">
        </el-pagination>
      </el-row>
    </section>
  </div>
</template>

<script>
  export default {
    data () {
      return {
        pagination : { //分页后的留言列表
          current : 1 , //当前页
          total : null , //记录条数
          size : 10 //每页条数
        } ,
        loading : false , //加载标识符
        score : [] , //咨询者成绩
        filter : null, //过滤参数
        formInline:{
          source:''
        }
      }
    } ,
    created () {
      this.getScore ()
      this.loading = true //数据加载则遮罩表格
    } ,
    methods : {
      resetGetScore(){
        this.formInline.source = ''
        this.getScore()
      },
      getScore () {
        let userId = this.$cookies.get ( "cid" )
        this.$axios (
          {
            methods : 'get' ,
            url : '/api/findEvaluation' ,
            params : {
              page : this.pagination.current ,
              size : this.pagination.size ,
              userId : userId,
              source:this.formInline.source
            }
          }
        ).then ( res => {
          if ( res.data.code == 200 ) {
            this.loading = false //数据加载完成去掉遮罩
            this.score = res.data.data.records
            this.pagination = { ... res.data.data }
          }
        } )
      } ,
      //改变当前记录条数
      handleSizeChange ( val ) {
        this.pagination.size = val
        this.getScore ()
      } ,
      //改变当前页码，重新发送请求
      handleCurrentChange ( val ) {
        this.pagination.current = val
        this.getScore ()
      } ,
      formatter ( row , column ) {
        return row.address;
      } ,
      filterTag ( value , row ) {
        return row.tag === value;
      } ,
      filterHandler ( value , row , column ) {
        const property = column[ "property" ];
        return row[ property ] === value;
      },
      view(row){
        this.$router.push ( {
          path : '/studentScore' , query : {
            source : row.source ,
            eid : row.id
          }
        } )
      }
    }
  };
</script>

<style lang="scss" scoped>
  .pagination {
    padding-top: 20px;
  }

  .table {
    width: 85%;
    margin: 0 auto;

    .title {
      margin: 20px;
    }

    .content-el {
      background-color: #fff;
      padding: 20px;
      margin-top: 30px;
    }
  }
</style>
